import router from '../router/index'
// import Cookies from 'js-cookie'
export function setupPermission() {
  router.beforeEach((to, from, next) => {
    if (!from.name && from.path !== '/') {
      next('/')
    } else if (to.path != '/login') {
      if (localStorage.getItem('userInfo')) {
        next()
      } else {
        next({ path: '/login' })
      }
    } else {
      next()
    }
  })
}
